package com.ferryc.modules.sys.web;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ferryc.commons.web.BaseController;
import com.ferryc.modules.sys.entity.param.SysLogInfoParam;
import com.ferryc.modules.sys.service.ISysLogInfoService;

@Controller
@RequestMapping("/log")
public class LogInfoController extends BaseController {

	@Autowired
	private ISysLogInfoService sysLogInfoService;

	@RequiresPermissions("log")
	@GetMapping("/")
	public String manage() {
		return "sys/log/list";
	}

	@RequiresPermissions("log")
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	@ResponseBody
	public Object list(SysLogInfoParam sysLogInfoParam, Model model) {
		return sysLogInfoService.selectPage(sysLogInfoParam.toSysLogInfo());
	}

	@RequiresPermissions("log_view")
	@GetMapping("/view")
	public Object view(SysLogInfoParam sysLogInfoParam, Model model) {
		model.addAttribute("info", sysLogInfoService.get(sysLogInfoParam.getId()));
		return "sys/log/view";
	}

}
